﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Reflection;
using SalePartial.IDAL;

namespace SalePartial.DALFactory
{
    /// <summary>
    /// This class is implemented following the Abstract Factory pattern to create the DAL implementation
    /// specified from the configuration file
    /// </summary>
    public sealed class DataAccess
    {

        // Look up the DAL implementation we should be using
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        private static readonly string orderPath = ConfigurationManager.AppSettings["OrdersDAL"];

        private DataAccess() { }

        public static IXPUserProfile CreateXPUserProfile()
        {
            string className = path + ".XPUserProfile";
            return (IXPUserProfile)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPCompany CreateXPCompany()
        {
            string className = path + ".XPCompany";
            return (IXPCompany)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPCompanyProduct CreateXPCompanyProduct()
        {
            string className = path + ".XPCompanyProduct";
            return (IXPCompanyProduct)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPCompanyCert CreateXPCompanyCert()
        {
            string className = path + ".XPCompanyCert";
            return (IXPCompanyCert)Assembly.Load(path).CreateInstance(className);
        }

        public static ICategories CreateCategories()
        {
            string className = path + ".Categories";
            return (ICategories)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPInquiry CreateXPInquiry()
        {
            string className = path + ".XPInquiry";
            return (IXPInquiry)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPDeliveryAddres CreateXPDeliveryAddres()
        {
            string className = path + ".XPDeliveryAddres";
            return (IXPDeliveryAddres)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPFavoriteVedor CreateXPFavoriteVedor()
        {
            string className = path + ".XPFavoriteVedor";
            return (IXPFavoriteVedor)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPInquiryEvent CreateXPInquiryEvent()
        {
            string className = path + ".XPInquiryEvent";
            return (IXPInquiryEvent)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPQuote CreateXPQuote()
        {
            string className = path + ".XPQuote";
            return (IXPQuote)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPRating CreateXPRating()
        {
            string className = path + ".XPRating";
            return (IXPRating)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPNotification CreateXPNotification()
        {
            string className = path + ".XPNotification";
            return (IXPNotification)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPNews CreateXPNews()
        {
            string className = path + ".XPNews";
            return (IXPNews)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPNewsCateGory CreateXPNewsCateGory()
        {
            string className = path + ".XPNewsCateGory";
            return (IXPNewsCateGory)Assembly.Load(path).CreateInstance(className);
        }

        public static IXPNewsComment CreateXPNewsComment()
        {
            string className = path + ".XPNewsComment";
            return (IXPNewsComment)Assembly.Load(path).CreateInstance(className);
        }

    }
}
